<#include "../common/header.htm">
<div class="content-wrapper">
    <section class="content">
        <div class="row">
            <div class="keyword-header">
                <label class="kWord">关键字</label>
                <input type="text" class="kWord-input" id="keyword">
                <input type="button" value="分析" class="kWord-btn kWord-inquire" onclick="queryList();">
                <input type="button" value="新增" class="kWord-btn kWord-newAdd">
            </div>
            <div class="box-body table-responsive">
				<table id="table" class="table text-nowrap"></table>
			</div>
        </div>
    </section>
</div>
<script>
	function queryList(){
		$("#table").bootstrapTable('destroy');
		firstTable();
	};
    $(".kWord-newAdd").click(function(){
        window.location.href="${ctx}/mquestion/capacitynewadd";
    });
    window.onload= firstTable;
    /*bootstrap table*/
    function firstTable(){
        $('#table').bootstrapTable({
            method : 'post', // 服务器数据的请求方式 get or post
            contentType : "application/x-www-form-urlencoded",
            url:"${ctx}/mquestion/getAllQuestion",//请求数据url
            queryParams: function (params) {
            	var keyword = $.trim($("#keyword").val());
                return {
                    pageNumber: (params.offset / params.limit),  //页码
                    pageSize: params.limit,  //页面大小
                    keyword : keyword
                };
            },
            striped: true,                      //是否显示行间隔色
            showHeader : true,
            pagination: true,                   //是否显示分页（*）
            sidePagination : 'server',//服务器端分页
            paginationLoop:false,
            resizable:true,
            resizeMode:'flex',
            pageNumber : 1,
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [15, 20, 50,100],//分页步进值
            //表格的列
            columns: [
                {
                    field: 'qid',//域值
                    title: '序号',//内容
                    visible: true,//false表示不显示
                },
                {
                    field: 'question',//域值
                    title: '问题',//内容
                    visible: true,//false表示不显示
                },
				{
                    field: 'sbparticiples',//域值
                    title: '关键词',//内容
                    visible: true,//false表示不显示
                },

                {
                    title: '操作',//内容
                    align:'center',
                    visible: true,//false表示不显示
                    formatter: function(value, row, index){
                        var html='<span class="edit-btn" onclick="editQuestion(\''+row.qid+'\')">';
                        html +='<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>编辑</span>';
                        html+='<span class="trash-btn" onclick="deleteQuestion(\''+row.qid+'\')">';
                        html+='<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除</span>';
                        return html;
                    }
                }
            ],
            onLoadSuccess: function (result) {
            }
        });
    };
    function editQuestion(qid){
   		window.location.href="${ctx}/mquestion/capacitynewadd?qid="+qid;
    };
    function deleteQuestion(qid){
   	 $.ajax({
        	type : "post",
            url : "${ctx}/mquestion/deleteQuestion",
            contentType : "application/json;charset=UTF-8",
            data : JSON.stringify({"qid" : qid}),
            success : function (data) {
         		 window.location.reload();
            }
        });
    };
</script>
<style>
    .content {
        background-color: #eef3f7;
    }
    .row{
        background-color: white;
        padding: 10px 28px 10px 37px;
    }
    .kWord{
        color: #6f7689;
        font-size: 14px;
        font-weight: 400;
    }
    .keyword-header{
        margin-bottom: 10px;
    }
    .kWord-input{
        width: 250px;
        height: 30px;
        border-radius: 4px;
        border: 1px solid #e4e4e4;
        margin-left: 15px;
        outline:none;
        padding: 0 8px 0 8px;
    }
    .kWord-btn{
        width: 70px;
        margin-left: 15px;
        background-color: #4695ed;
        height: 30px;
        font-size: 14px;
        border: 1px solid transparent;
        color: white;
        border-radius: 4px;
    }
    .kWord-btn:hover{
        background-color: #3296f1;
    }
    .kWord-btn:active{
        background-color: #0c76d7;
    }
    .edit-btn{
        margin-right: 10px;
        cursor: pointer;
    }
    .edit-btn:hover,.trash-btn:hover{
        color: #4595ec;
    }
    .trash-btn{
        cursor: pointer;
    }
    span.glyphicon-edit,span.glyphicon-trash {
        margin-right: 5px;
    }
    .fixed-table-body{
        overflow-x: hidden;
    }
</style>